package concurrent.executors;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import security.DateUtils;

public class HeartBeat {

  public static void main(String[] args) {
    ScheduledExecutorService executor = Executors.newScheduledThreadPool(5);
    Runnable task = new Runnable() {
      public void run() {
        System.out.println("HeartBeat.........................");
      }
    };
    executor.scheduleAtFixedRate(task, 5, 3, TimeUnit.SECONDS);   //5秒后第一次执行，之后每隔3秒执行一次
  }
}
